/*
 * package com.petRescueCenter.demo.common.web;
 * 
 * import java.io.IOException;
 * 
 * import javax.servlet.FilterChain; import javax.servlet.ServletException;
 * import javax.servlet.ServletRequest; import javax.servlet.ServletResponse;
 * import javax.servlet.http.HttpServletRequest; import
 * javax.servlet.http.HttpServletResponse;
 * 
 * import org.springframework.context.annotation.Configuration; import
 * org.springframework.web.bind.annotation.RequestMethod; import
 * org.springframework.web.servlet.config.annotation.CorsRegistry; import
 * org.springframework.web.servlet.config.annotation.EnableWebMvc; import
 * org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
 * 
 * @Configuration
 * 
 * @EnableWebMvc public class WebConfig extends WebMvcConfigurerAdapter {
 * 
 * @Override public void addCorsMappings(CorsRegistry registry) {
 * registry.addMapping("/**").allowedOrigins("*") .allowedMethods("GET", "POST",
 * "PUT", "OPTIONS", "DELETE", "PATCH").allowCredentials(true).maxAge(3600); }
 * 
 * public void doFilter(ServletRequest request, ServletResponse response,
 * FilterChain chain) throws IOException, ServletException { HttpServletResponse
 * response1 = (HttpServletResponse) response; HttpServletRequest request1 =
 * (HttpServletRequest) request;
 * response1.setHeader("Access-Control-Allow-Origin", "*");
 * response1.setHeader("Access-Control-Allow-Credentials", "true");
 * response1.setHeader("Access-Control-Allow-Methods", "*");
 * response1.setHeader("Access-Control-Allow-Headers",
 * "Content-Type,Access-Token");
 * response1.setHeader("Access-Control-Expose-Headers", "*");
 * 
 * if (request1.getMethod().equals(RequestMethod.OPTIONS.toString())) {
 * System.out.println("-----检查------"); return; } chain.doFilter(request,
 * response); }
 * 
 * }
 */